var basePath = $("#basePath").val();
function getTime() {
    var dateObj = new Date();

    var year = dateObj.getFullYear();//年
    var month = dateObj.getMonth() + 1;//月  (注意：月份+1)
    var date = dateObj.getDate();//日
    var day = dateObj.getDay();
    var weeks = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
    var week = weeks[day];//根据day值，获取星期数组中的星期数。
    var hours = dateObj.getHours();//小时
    var minutes = dateObj.getMinutes();//分钟
    var seconds = dateObj.getSeconds();//秒

    if (month < 10) {
        month = "0" + month;
    }
    if (date < 10) {
        date = "0" + date;
    }
    if (hours < 10) {
        hours = "0" + hours;
    }
    if (minutes < 10) {
        minutes = "0" + minutes;
    }
    if (seconds < 10) {
        seconds = "0" + seconds;
    }

    var newDate = year + "年" + month + "月" + date + "日" + "(" + week + ")" + "&nbsp;&nbsp" + hours + ":" + minutes + ":" + seconds;
    document.getElementById("date-time").innerHTML = newDate;//在div中写入时间
    setTimeout('getTime()', 500);//每隔500ms执行一次getTime()
}
/*============================试题提交前进行权限验证============================================*/
function  volidateAuthorizationForSubmit() {
    var flag = true;
    $.ajax({
        url: basePath.value+"/examination/volidateAuthorizationForSubmit",
        type: "GET",
        dataType: "json",
        success: function (obj) {
            if (obj.code != null && obj.code == 200) {
                layer.msg(obj.msg, {icon: 5, time: 2000});
                flag = false;
            }
        }
    });
    return flag;
}
/*============================试题提交前进行权限验证============================================*/


var wendaAcupointLocationCount = 1,wendaAnswerMayorCureCount=1
    ,acupointLocationAdultCount=1,acupointLocationPediatricCount=1,wendaNSFECCount=1,
    singlePloyCECCount=1,completePloyFSENCount=1;
/***************************************每次切换分类将增加次数重置****************************************/
$(document).ready(function () {
    $(".rdobox").click(function(){
        wendaNSFECCount = 1;
        wendaAcupointLocationCount = 1;
        wendaAnswerMayorCureCount = 1;
        acupointLocationAdultCount=1;
        acupointLocationPediatricCount=1;
        singlePloyCECCount = 1;
        completePloyFSENCount = 1;
    });
});
/***************************************每次切换分类将增加次数重置****************************************/

/*============================增加定位、主治或者答案============================================*/
function addTerms(divId,count,msg,category) {
    switch (category) {
        //增加-问答题-腧穴题-定位
        case "wendaAcupointLocation":
            if (wendaAcupointLocationCount > count) {
                // 询问框
                layer.confirm(msg, {
                    btn: ["确认"]
                    // 按钮
                });
            } else {
                wendaAcupointLocationCount = wendaAcupointLocationCount + 1;
                var content = "<div class='form-group'><div class='col-sm-2'></div><div class='col-sm-6 '><input type='text' class='form-control' name='answerWD' parsley-trigger='change'  required maxlength='250'data-parsley-maxlength='250' placeholder='请输入定位答案......' /></div><label class='col-sm-1 control-label' style='padding-left:10px'>分值</label><div class='col-sm-2 '><input type='text' class='form-control' name='answerWDScore' parsley-trigger='change'  required 	 data-parsley-range='[0,"+maxLocationScoreWD+"]'/></div><div class='col-md-1'><i onclick='deleteNewAdd(this,\"wendaAcupointLocationCount\")' class='glyphicon glyphicon-remove' style='margin-left: 80%;margin-top:12%;cursor: pointer;'></i></div></div>";
                $(divId).append(content);
            }
            break;
        //增加-问答题-腧穴题-主治
        case "wendaAcupointMayorCure":
            if (wendaAnswerMayorCureCount > count) {
                // 询问框
                layer.confirm(msg, {
                    btn: ["确认"]
                    // 按钮
                });
            } else {
                wendaAnswerMayorCureCount = wendaAnswerMayorCureCount + 1;
                var content = "<div class='form-group'><div class='col-sm-2'></div><div class='col-sm-6 '><input type='text' class='form-control' name='answerWD1' parsley-trigger='change'  required maxlength='250'data-parsley-maxlength='250' placeholder='请输入定位答案......'/></div><label class='col-sm-1 control-label' style='padding-left:10px'>分值</label><div class='col-sm-2 '><input type='text' class='form-control' name='answerWDScore1' parsley-trigger='change'  required  data-parsley-range='[0,"+maxMayorCureScoreWD+"]'/></div><div class='col-md-1'><i onclick='deleteNewAdd(this,\"wendaAnswerMayorCureCount\")' class='glyphicon glyphicon-remove' style='margin-left: 80%;margin-top:12%;cursor: pointer;'></i></div></div>";
                $(divId).append(content);
            }
            break;
        //增加-问答题-腧穴题-NSFEC
        case "wendaNSFEC":
            if (wendaNSFECCount > count) {
                // 询问框
                layer.confirm(msg, {
                    btn: ["确认"]
                    // 按钮
                });
            } else {
                wendaNSFECCount = wendaNSFECCount + 1;
                var content = "<div class='form-group'><div class='col-sm-2'></div><div class='col-sm-6 '><input type='text' class='form-control' name='answerWD2' parsley-trigger='change'  required maxlength='250'data-parsley-maxlength='250' placeholder='请输入答案......'/></div><label class='col-sm-1 control-label' style='padding-left:10px'>分值</label><div class='col-sm-2 '><input type='text' class='form-control' name='answerWDScore2' parsley-trigger='change'  required  data-parsley-range='[0,"+maxAnswerScoreWD+"]'/></div><div class='col-md-1'><i onclick='deleteNewAdd(this,\"wendaNSFECCount\")' class='glyphicon glyphicon-remove' style='margin-left: 80%;margin-top:12%;cursor: pointer;'></i></div></div>";
                $(divId).append(content);
            }
        break;
        //增加-穴位定位-成人穴位-定位
        case "acupointLocationAdultLocation":
            debugger
            if (acupointLocationAdultCount > count) {
                // 询问框
                layer.confirm(msg, {
                    btn: ["确认"]
                    // 按钮
                });
            } else {
                acupointLocationAdultCount = acupointLocationAdultCount + 1;
                var content = "<div class='form-group'><div class='col-sm-2'></div><div class='col-sm-6 '><input type='text' class='form-control' name='answerXWDW' parsley-trigger='change'  required maxlength='250'data-parsley-maxlength='250' placeholder='请输入定位答案......'/></div><label class='col-sm-1 control-label' style='padding-left:10px'>分值</label><div class='col-sm-2 '><input type='text' class='form-control' name='answerXWDWScore' parsley-trigger='change'  required  data-parsley-range='[0,"+maxLocationScoreXWDWAdult+"]'/></div><div class='col-md-1'><i onclick='deleteNewAdd(this,\"acupointLocationAdultCount\")' class='glyphicon glyphicon-remove' style='margin-left: 80%;margin-top:12%;cursor: pointer;'></i></div></div>";
                $(divId).append(content);
            }
            break;
        //增加-穴位定位-儿科穴位-定位
        case "acupointLocationPediatricLocation":
            debugger
            if (acupointLocationPediatricCount > count) {
                // 询问框
                layer.confirm(msg, {
                    btn: ["确认"]
                    // 按钮
                });
            } else {
                acupointLocationPediatricCount = acupointLocationPediatricCount + 1;
                var content = "<div class='form-group'><div class='col-sm-2'></div><div class='col-sm-6 '><input type='text' class='form-control' name='answerXWDW1' parsley-trigger='change'  required maxlength='250'data-parsley-maxlength='250' placeholder='请输入定位答案......'/></div><label class='col-sm-1 control-label' style='padding-left:10px'>分值</label><div class='col-sm-2 '><input type='text' class='form-control' name='answerXWDWScore1' parsley-trigger='change'  required  data-parsley-range='[0,"+maxLocationScoreXWDWPediatric+"]'/></div><div class='col-md-1'><i onclick='deleteNewAdd(this,\"acupointLocationPediatricCount\")' class='glyphicon glyphicon-remove' style='margin-left: 80%;margin-top:12%;cursor: pointer;'></i></div></div>";
                $(divId).append(content);
            }
            break;
        //增加-单项手法-CEC
        case "singlePloyCEC":
            if (singlePloyCECCount > count) {
                // 询问框
                layer.confirm(msg, {
                    btn: ["确认"]
                    // 按钮
                });
            } else {
                singlePloyCECCount = singlePloyCECCount + 1;
                var content = "<div class='form-group'><div class='col-sm-2'></div><div class='col-sm-6 '><input type='text' class='form-control' name='answerDXSF' parsley-trigger='change'  required maxlength='250'data-parsley-maxlength='250'placeholder='请输入答案......'/></div><label class='col-sm-1 control-label' style='padding-left:10px'>分值</label><div class='col-sm-2 '><input type='text' class='form-control' name='answerDXSFScore' parsley-trigger='change'  required  data-parsley-range='[0,"+maxAnswerScoreDXSF+"]'/></div><div class='col-md-1'><i onclick='deleteNewAdd(this,\"singlePloyCECCount\")' class='glyphicon glyphicon-remove' style='margin-left: 80%;margin-top:12%;cursor: pointer;'></i></div></div>";
                $(divId).append(content);
            }
            break;
        //增加-成套手法-FSEN
        case "completePloyFSEN":
            if (completePloyFSENCount > count) {
                // 询问框
                layer.confirm(msg, {
                    btn: ["确认"]
                    // 按钮
                });
            } else {
                completePloyFSENCount = completePloyFSENCount + 1;
                var content = "<div class='form-group'><div class='col-sm-2'></div><div class='col-sm-6 '><input type='text' class='form-control' name='answerCTSF' parsley-trigger='change'  required maxlength='250'data-parsley-maxlength='250'placeholder='请输入答案......'/></div><label class='col-sm-1 control-label' style='padding-left:10px'>分值</label><div class='col-sm-2 '><input type='text' class='form-control' name='answerCTSFScore' parsley-trigger='change'  required  data-parsley-range='[0,"+maxAnswerScoreCTSF+"]'/></div><div class='col-md-1'><i onclick='deleteNewAdd(this,\"completePloyFSENCount\")' class='glyphicon glyphicon-remove' style='margin-left: 80%;margin-top:12%;cursor: pointer;'></i></div></div>";
                $(divId).append(content);
            }
            break;

        default:
    }
}
/*============================增加定位、主治或者答案============================================*/

/**************************************************************删除新增项****************************************************/
function deleteNewAdd(obj, countName) {
    $(obj).parent().parent().remove();
    switch (countName) {
        case "wendaAcupointLocationCount":
            wendaAcupointLocationCount = wendaAcupointLocationCount - 1;
            break;
        case "wendaAnswerMayorCureCount":
            wendaAnswerMayorCureCount = wendaAnswerMayorCureCount - 1;
            break;
        case "wendaNSFECCount":
            wendaNSFECCount = wendaNSFECCount - 1;
        case "acupointLocationAdultCount":
            acupointLocationAdultCount = acupointLocationAdultCount - 1;
            break;
        case "acupointLocationPediatricCount":
            acupointLocationPediatricCount = acupointLocationPediatricCount - 1;
        case "singlePloyCECCount":
            singlePloyCECCount = singlePloyCECCount - 1;
            break;
        case "completePloyFSENCount":
            completePloyFSENCount = completePloyFSENCount - 1;
            break;
        default:
    }
}
/**************************************************************删除新增项****************************************************/

/**************************************************************切换试题分类后获取对应试题参数值****************************************************/

/**************************************************************切换试题分类后获取对应试题参数值****************************************************/
